#include "../core.h"

namespace sfc::serial {

struct Node {
  enum Tag { Null, Bool, Int, Flt, List, Dict };

  Tag _tag;  // 4
  u32 _len;  // 4
  union {    // 8
    bool _bool;
    i64 _i64;
    f64 _f64;
    u8* _str;
    Node* _vec;
  };

  Node();
  Node(Node&& other) noexcept;
  ~Node();

  static auto null() -> Node;
  static auto dict() -> Node;
  static auto list() -> Node;

  static auto from_bool(bool val) -> Node;
  static auto from_i64(i64 val) -> Node;
  static auto from_f64(f64 val) -> Node;
  static auto from_str(Str val) -> Node;

  auto operator[](u64 idx) const -> const Node&;
  auto operator[](u64 idx) -> Node&;

  auto operator[](Str key) const -> const Node&;
  auto operator[](Str key) -> Node&;
};

struct List;

struct Dict;

}  // namespace sfc::serial
